package com.ttx.ch05;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.stream.Stream;

public class FileStream {
    public static void main(String[] args) {
        final Path path = Paths.get(".", "pom.xml");
        System.out.println(path.getFileName());

        try {
            final Stream<String> lines = Files.lines(path, Charset.defaultCharset());
            final long count = lines.flatMap(l -> Arrays.stream(l.split("")))
                    .distinct()
                    .count();
            System.out.println("不重复的单词个数：" + count);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
